package scut.facerecognition.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import scut.facerecognition.entity.pojo.PostLike;

/**
 * 帖子点赞 Mapper 接口
 */
@Mapper
public interface PostLikeMapper extends BaseMapper<PostLike> {
    
    /**
     * 查询用户是否点赞过指定帖子
     * @param postId 帖子ID
     * @param userId 用户ID
     * @return 如果存在点赞记录则返回记录ID，否则返回null
     */
    @Select("SELECT id FROM post_like WHERE post_id = #{postId} AND user_id = #{userId} LIMIT 1")
    Long isPostLikedByUser(@Param("postId") Long postId, @Param("userId") Long userId);
}
